package nix.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class JServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String addr = request.getRemoteAddr();
		String method = request.getMethod();
		String userAgent = request.getHeader("User-Agent");

		PrintWriter pw = response.getWriter();

		pw.println(addr);
		pw.println(method);
		pw.println(userAgent);

		if (userAgent.toLowerCase().contains("chrome")) {
			pw.println("Chrome");
		} else if (userAgent.toLowerCase().contains("msie")) {
			pw.println("IE");
		} else if (userAgent.toLowerCase().contains("firefox")) {
			pw.println("Firefox");
		}

		pw.println("Referer: " + request.getHeader("Referer"));

		pw.flush();
		pw.close();
	}

}
